<?php

/**
 * 后台路由
 */
use Illuminate\Support\Facades\Route;


Route::name('admin.')->group(function(){
	Route::get('/relogin',function (){
	    echo "<script>parent.location.href='/admin/login';</script>";
	})->name('relogin');
	//不需要登录
	Route::get('/login', 'LoginController@login')->name('login')->middleware('logged:admin');
	Route::post('/dologin', 'LoginController@doLogin')->name('dologin');
	Route::middleware(['auth:admin', 'checkPermission','operatorLog'])->group(function(){
		//入口页面
		Route::get('/','HomeController@index')->name('home');
		//退出登录
		Route::get('/logout', 'LoginController@logout')->name('logout');
		//个人中心
		Route::get('/profile', 'ProfileController@info')->name('profile');
		Route::put('profile/update', 'ProfileController@update')->name('profile.update');
		//仪表盘
		Route::get('/dashboard', 'DashboardController@index')->name('dashboard');
		Route::get('/setPassword', 'DashboardController@setPassword')->name('setPassword');
		Route::post('/setPassword/Store', 'DashboardController@setPasswordStore')->name('setPassword.store');
		//权限管理
		Route::resource('/permissions', 'PermissionController');
		//角色管理
		Route::get('roles/permissions', 'RoleController@getPermissions')->name('roles.getPermissions');
		Route::post('role/setPermissions', 'RoleController@setPermissionStore')->name('roles.setPermissionStore');
		Route::get('/roles/setpermissions/{role}', 'RoleController@setPermissions')->name('roles.setPermissions');
		Route::resource('/roles', 'RoleController');
		//后台管理员
		Route::post('managers/delete', 'AdminUserController@delete')->name('managers.delete');
		Route::get('managers/permissions', 'AdminUserController@getRoles')->name('managers.getRoles');
		Route::get('/managers/setRole/{manager}','AdminUserController@setRole')->name('managers.setRole');
		Route::post('managers/setRoleStore', 'AdminUserController@setRoleStore')->name('managers.setRoleStore');
		Route::resource('/managers', 'AdminUserController');

		//经销商管理
		Route::get('brokers/list','BrokerController@list')->name('brokers.lists');
		Route::post('brokers/resetPassword', 'BrokerController@resetPassword')->name('brokers.resetPassword');
		Route::post('brokers/delete', 'BrokerController@delete')->name('brokers.delete');
		Route::get('/brokers/setRole/{broker}','BrokerController@setRole')->name('brokers.setRole');
		Route::get('brokers/permissions', 'BrokerController@getRoles')->name('brokers.getRoles');
		Route::post('brokers/setRoleStore', 'BrokerController@setRoleStore')->name('brokers.setRoleStore');
		//分配设备
		Route::get('brokers/allocation/{broker}', 'BrokerController@allocation')->name('brokers.allocation');
		Route::post('brokers/allocation', 'BrokerController@allocationStore')->name('brokers.allocationStore');
		Route::get('brokers/machines', 'BrokerController@machines')->name('brokers.machines');
		Route::resource('brokers', 'BrokerController');
		
		//商户管理
		Route::put('merchants/jdupdate/{id}','MerchantController@jdupdate')->name('jds.update');
		Route::get('merchants/jdedit/{id}','MerchantController@jdedit')->name('jds.edit');
		Route::get('merchants/jdList', 'MerchantController@jdList')->name('merchants.jdList');
		Route::post('merchants/resetPassword', 'MerchantController@resetPassword')->name('merchants.resetPassword');
		Route::get('merchants/lists', 'MerchantController@lists')->name('merchants.lists');
		Route::post('merchants/delete', 'MerchantController@delete')->name('merchants.delete');
		Route::get('merchants/permissions', 'MerchantController@getRoles')->name('merchants.getRoles');
		Route::get('/merchants/setRole/{merchant}','MerchantController@setRole')->name('merchants.setRole');
		Route::post('merchants/setRoleStore', 'MerchantController@setRoleStore')->name('merchants.setRoleStore');
		Route::get('merchants/allocation/{merchant}', 'MerchantController@allocation')->name('merchants.allocation');
		Route::post('merchants/allocation', 'MerchantController@allocationStore')->name('merchants.allocationStore');
		Route::get('merchants/machines', 'MerchantController@machines')->name('merchants.machines');
		Route::resource('merchants', 'MerchantController');	

		//操作员
		Route::get('operators/lists', 'OperatorController@lists')->name('operators.lists');
		Route::post('operators/resetPassword', 'OperatorController@resetPassword')->name('operators.resetPassword');
		Route::post('operators/delete', 'OperatorController@delete')->name('operators.delete');
		Route::get('/operators/setRole/{operator}','OperatorController@setRole')->name('operators.setRole');
		Route::get('operators/permissions', 'OperatorController@getRoles')->name('operators.getRoles');
		Route::post('operators/setRoleStore', 'OperatorController@setRoleStore')->name('operators.setRoleStore');
		//分配设备
		Route::get('operators/allocation/{operator}', 'OperatorController@allocation')->name('operators.allocation');
		Route::post('operators/allocation', 'OperatorController@allocationStore')->name('operators.allocationStore');
		Route::get('operators/machines', 'OperatorController@machines')->name('operators.machines');
		Route::resource('operators', 'OperatorController');
		//设备管理
		//商品列表
		Route::post('machines/delAbImage','MachineController@delAbImage')->name('machines.delAbImage');
		Route::post('machines/addAbImage','MachineController@addAbImage')->name('machines.addAbImage');
		Route::post('machines/abImageUpload', 'MachineController@upload')->name('machines.abImageUpload');
		Route::get('machines/abImages', 'MachineController@abImageList')->name('machines.abImages');
		Route::post('machines/paramsSettings', 'MachineController@paramsSettings')->name('machines.paramsSettings');
		Route::post('machines/clearFreightError', 'MachineController@clearFreightError')->name('machines.clearFreightError');
		Route::get('machines/restart', 'MachineController@restart')->name('machines.restart');
		Route::put('machines/freightDemos/update', 'MachineController@freightDemoUpdate')->name('machines.freightDemoUpdate');
		Route::get('machines/deleteOrder','MachineController@deleteOrder')->name('machines.deleteOrder');
		Route::post('machines/reset','MachineController@reset')->name('machines.resetMachine');
		Route::get('machines/orders', 'MachineController@orders')->name('machines.orders');
		Route::get('machines/outAll','MachineController@outAll')->name('machines.outAll');
		Route::post('machines/changeMerchant', 'MachineController@changeMerchant')->name('machines.changeMerchant');
		Route::post('machines/bindMachines', 'MachineController@bindMachines')->name('machines.bindMachines');
		Route::get('machines/getChildrenAll', 'MachineController@getChildrenAll')->name('machines.getChildrenAll');
		Route::post('machines/delete', 'MachineController@delete')->name('machines.delete');
		Route::post('machines/freight/updateData', 'MachineController@freightUpdateData')->name('machines.freightUpdateData');
		Route::put('machines/freight/bindGoods', 'MachineController@freightBindGoods')->name('machines.freightBindGoods');
		Route::post('machines/freight/edit', 'MachineController@freightEdit')->name('machines.freightEdit');
		Route::get('machines/freight/qrcode', 'MachineController@freightQrcode')->name('machines.freightQrcode');
		Route::post('machines/qrcode/download', 'MachineController@downloadQrcode')->name('machines.downloadQrcode');
		Route::get('machines/qrcode', 'MachineController@qrcode')->name('machines.qrcode');
		Route::get('machines/info', 'MachineController@info')->name('machines.info');
		Route::get('machines/lists', 'MachineController@lists')->name('machines.lists');
		Route::get('machines/checkUnique', 'MachineController@checkUnique')->name('machines.checkUnique');
		Route::get('machines/freights/open', 'MachineController@freightOpen')->name('machines.freightOpen');
		Route::put('machines/freights/addStock', 'MachineController@freightAddStock')->name('machines.freightAddStock');
		Route::put('machines/freights/update', 'MachineController@freightUpdate')->name('machines.freightUpdate');
		Route::get('machines/goodsLists', 'MachineController@goodsLists')->name('machines.goodsLists');
		Route::get('machine/settings/{machine}', 'MachineController@config')->name('machines.config');		
		Route::resource('machines', 'MachineController');		
		Route::put('machine/settings/update', 'MachineController@configUpdate')->name('machines.configUpdate');
		//获取设备的相关货道
		Route::get('machine/freights', 'MachineController@freight')->name('machines.freight');

		

		//货道模板
		Route::post('freightWayDemos/delete', 'FreightWayDemoController@delete')->name('freightWayDemos.delete');

		Route::resource('freightWayDemos','FreightWayDemoController');
		Route::get('freightWayDemo/settings/{freightWayDemo}', 'FreightWayDemoController@config')->name('freightWayDemos.config');
		Route::get('freightWayDemo/settings/{freightWayDemoData}/edit', 'FreightWayDemoController@configEdit')->name('freightWayDemoDatas.edit');
		Route::post('freightWayDemo/settings', 'FreightWayDemoController@configUpdate')->name('freightWayDemoDatas.update');
		Route::get('freightWayDemo/lists', 'FreightWayDemoController@lists')->name('freightWayDemo.lists');
		//主板类型
		Route::get('mainborads/list', 'MainboradController@list')->name('mainborads.lists');
		Route::post('mainborads/delete', 'MainboradController@delete')->name('mainborads.delete');
		Route::get('mainborads/details', 'MainboradController@detail')->name('mainborads.detail');
		Route::resource('mainborads','MainboradController');
		Route::get('mainborad/settings/lists', 'MainboradController@configLists')->name('mainborads.configLists');
		Route::get('mainborad/settings/{mainborad}', 'MainboradController@config')->name('mainborads.config');
		Route::post('mainborad/settings/{mainborad}', 'MainboradController@configStore')->name('mainborads.configStore');
		Route::delete('mainborad/settings', 'MainboradController@configDestroy')->name('mainborads.configDestroy');	
		Route::get('mainborad/lists', 'MainboradController@lists')->name('mainborad.lists');
		
		//商户编码列表
		Route::get('/userscode', 'UsersCodeController@index')->name('userscode.index');
		//添加商户编码
		Route::get('/userscode/create', 'UsersCodeController@create')->name('userscode.created'); 
		Route::post('/userscode/store', 'UsersCodeController@store')->name('userscode.store');
		//修改商户编码
		Route::get('/userscode/edit/{userscodeid}', 'UsersCodeController@edit')->name('userscode.edit');
		Route::post('/userscode/update', 'UsersCodeController@update')->name('userscode.update');
		//删除商户编码
		Route::delete('/userscode/{usersCode}', 'UsersCodeController@destroy')->name('userscode.destroy');
		//商品管理
		//Route::resource('/goodstype', 'GoodsTypeController');
		// 云图库
		Route::get('/goods/cloud', 'GoodsController@cloud')->name('goods.cloud');
		Route::get('/cloudimage', 'CloudImageController@index')->name('cloudimage.index');
		//Route::get('/cloudimage', 'CloudImageController@lstcloud')->name('cloudimage.lstcloud');
		Route::get('/cloudimage/create', 'CloudImageController@create')->name('cloudimage.created');
		Route::post('/cloudimage/store', 'CloudImageController@store')->name('cloudimage.add');
		Route::post('/cloudimage/upload', 'CloudImageController@uploadImage')->name('cloudimage.upload');
		Route::get('/goods/cloudcs/{goodsid}', 'GoodsController@cloudcs')->name('goods.cloudcs');
		
		//云图库图片分类
		Route::get('/cloudimageType', 'CloudimageTypeController@index')->name('cloudimagetype.index');
		//添加云图库图片分类
		Route::get('/cloudimageType/create', 'CloudimageTypeController@create')->name('cloudimagetype.created');
		Route::post('/cloudimageType/store', 'CloudimageTypeController@store')->name('cloudimagetype.add');
		//修改云图库图片分类
		Route::get('/cloudimageType/edit/{cloudimagetypeid}', 'CloudimageTypeController@edit')->name('cloudimagetype.edit');
		Route::post('/cloudimageType/update', 'CloudimageTypeController@update')->name('cloudimagetype.update');
		//删除云图库图片分类
		Route::delete('/cloudimageType/{cloudimageType}', 'CloudimageTypeController@destroy')->name('cloudimagetype.destroy');

		// 展示商品列表
		Route::get('/goods', 'GoodsController@index')->name('goods.index');
		// 添加商品
		Route::get('/goods/create', 'GoodsController@create')->name('goods.created');
		Route::post('/goods/store', 'GoodsController@store')->name('goods.add');
		//修改商品
		Route::get('/goods/edit/{goodsid}', 'GoodsController@edit')->name('goods.edit');
		Route::post('/goods/update', 'GoodsController@update')->name('goods.update');
		//图片审核修改
		Route::get('/goods/toexamineedit/{goodsid}', 'GoodsController@toexamineedit')->name('goods.toexamineedit');
		Route::post('/goods/toexamineupdate', 'GoodsController@toexamineupdate')->name('goods.toexamineupdate');
		//删除分类
		Route::delete('/goods/{goods}', 'GoodsController@destroy')->name('goods.destroy');
		Route::post('/goods/upload', 'GoodsController@uploadImage')->name('goods.upload');
		//展示商品分类列表
		Route::get('/goodsType', 'GoodsTypeController@index')->name('goodstype.index');
		//添加商品分类
		Route::get('/goodsType/create', 'GoodsTypeController@create')->name('goodstype.created');
		Route::post('/goodsType/store', 'GoodsTypeController@store')->name('goodstype.add');
		//修改商品分类
		Route::get('/goodsType/edit/{goodstypeid}', 'GoodsTypeController@edit')->name('goodstype.edit');
		Route::post('/goodsType/update', 'GoodsTypeController@update')->name('goodstype.update');
		//删除商品分类
		Route::delete('/goodsType/{goodsType}', 'GoodsTypeController@destroy')->name('goodstype.destroy');

		//退款
		Route::post('/order/refoundOrder','OrderController@refoundOrder')->name('order.refoundOrder');
		//Route::get('/order/refundOrder','OrderController@refundOrder')->name('order.refundOrder');
	
		// 订单管理
		Route::get('/order', 'OrderController@index')->name('order.index');
		// 导出订单
		Route::get('order/putOrderExcel', 'OrderController@putOrderExcel')->name('order.putOrderExcel');
		//订单操作日志
		Route::get('/orderslog','OrdersLogController@index')->name('orderslog.index');
		//退货记录
		Route::get('/refund', 'RefundController@index')->name('refund.index');
		//补货记录
		Route::get('/replenishment', 'ReplenishmentController@index')->name('replenishment.index');
		//出货货记录
		Route::get('/shipment', 'ShipmentController@index')->name('shipment.index');
		//缺货统计
		Route::get('/outshop', 'OutshopController@index')->name('outshop.index');
		// 用户管理
		//Route::get('/theuser', 'TheUserController@index')->name('theuser.index');
		Route::resource('/payuser', 'PayUserController');
		// 展示广告轮播图列表
		Route::get('/adverimage', 'AdverImageController@index')->name('adverimage.index');
		// 添加广告轮播图
		Route::get('/adverimage/create', 'AdverImageController@create')->name('adverimage.created');
		Route::post('/adverimage/store', 'AdverImageController@store')->name('adverimage.add');
		//修改广告轮播图
		Route::get('/adverimage/edit/{goodsid}', 'AdverImageController@edit')->name('adverimage.edit');
		Route::post('/adverimage/update', 'AdverImageController@update')->name('adverimage.update');
		//删除广告轮播图
		Route::delete('/adverimage/{goods}', 'AdverImageController@destroy')->name('adverimage.destroy');
		Route::post('/adverimage/upload', 'AdverImageController@uploadImage')->name('adverimage.upload');
		
		//统统设置
		Route::get('/config', 'ConfigController@siteconfig')->name('config.siteconfig');
		Route::get('/information', 'ConfigController@information')->name('config.information');
		//百度推广基本系统设置
		Route::get('/baidu', 'ConfigController@baidu')->name('config.baidu');
		//系统入库
		Route::post('/config/store', 'ConfigController@store')->name('config.store');
		//公告管理
		Route::get('notices/noticeTotal', 'NoticeController@noticeTotal')->name('notices.noticeTotal');
		Route::get('notices/list','NoticeController@lists')->name('notices.lists');
		Route::get('/notices/publishNotice','NoticeController@publishNotice')->name('notices.publishNotice');
		Route::post('notices/delete', 'NoticeController@delete')->name('notices.delete');
		Route::resource('notices','NoticeController');
		//操作日志
		Route::get('/operatorLog','OperatorLogController@index')->name('operatorLog.index');
		//数据统计
		//缺货统计
		Route::get('statistics/putGoodsExcel', 'StatisticsController@putGoodsExcel')->name('statistics.putGoodsExcel');
		Route::get('statistics/outGoods', 'StatisticsController@outGoods')->name('statistics.outGoods');
		Route::get('statistics/ordersExcel', 'StatisticsController@ordersExcel')->name('statistics.ordersExcel');
		Route::get('statistics/orders', 'StatisticsController@orders')->name('statistics.orders');
		//图片审核
		Route::put('images/update', 'ImageController@update')->name('images.update');
		Route::post('images/upload', 'ImageController@upload')->name('images.upload');
		Route::get('images/all', 'ImageController@all')->name('images.all');
		Route::get('images','ImageController@index')->name('images.index');
		//测试页面
		Route::get('/test','TestController@test')->name('test');
		//Route::get('/rediscs', 'RediscsController@index')->name('rediscs.index');
		//财务管理
		Route::get('/financing','FinancingController@index')->name('financing.index');
		//设备操作日志
		Route::resource('mqttLogs','MqttLogController');
	});
});